package com.example.ormsqlsplicingframe1.sql.impl;

import com.example.ormsqlsplicingframe1.sql.ConditionSql;
import com.example.ormsqlsplicingframe1.sql.DeleteSql;

import java.util.ArrayList;
import java.util.List;
import java.util.StringJoiner;

public class DeleteImpl implements DeleteSql {

    private String table;

    ConditionImpl condition = new ConditionImpl();

    @Override
    public String getSql() {
        final String where = condition.getSql();


        String sql =  "delete from "+table ;

        if (where.length() >0){
            sql += " where "+where;
        }

        return sql;

    }

    @Override
    public List<Object> getValues() {
        return condition.getValues();
    }

    @Override
    public DeleteSql table(String table) {
        this.table = table;
        return this;
    }

    @Override
    public ConditionSql where() {
        return condition;
    }
}
